#ifndef X_5_H
#define X_5_H

#include "common.h"

// Line (composed of multiple line segments, x01, x15, x16, and x17)
template <AllegroVersion version>
struct x05
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;

    uint32_t k;

    uint32_t ptr0;

    // Points to `x04` (net/shape pair)
    uint32_t ptr1;

    uint32_t un1[2];

    // Points to one of: `x04`, `x05`, `0x09`, `x28`, `x2E`, `x32`, `x33` or
    // null.
    uint32_t ptr2[2];

    uint32_t un2;

    // Points to one of: `x04`, `x05`, `0x09`, `x28`, `x2E`, `x32`, `x33`.
    uint32_t ptr3[2];
#if __cplusplus >= 202002L
    COND_FIELD(version >= A_172, uint32_t, un4[3]);
#else
    uint32_t un4[1];
#endif
    // Points to one of: `0x01`, `x15, `x16`, `x17`.
    uint32_t first_segment_ptr;

    // Points to instance of `0x03` (nullable).
    uint32_t ptr5;

    // Null
    uint32_t un3;

    uint32_t TAIL;
    operator x05<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

#if __cplusplus < 202002L
template <> struct x05<A_172>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;

    uint32_t k;

    uint32_t ptr0;

    // Points to `x04` (net/shape pair)
    uint32_t ptr1;

    uint32_t un1[2];

    // Points to one of: `x04`, `x05`, `0x09`, `x28`, `x2E`, `x32`, `x33` or
    // null.
    uint32_t ptr2[2];

    uint32_t un2;

    // Points to one of: `x04`, `x05`, `0x09`, `x28`, `x2E`, `x32`, `x33`.
    uint32_t ptr3[2];

    uint32_t un4[3];

    // Points to one of: `0x01`, `x15, `x16`, `x17`.
    uint32_t first_segment_ptr;

    // Points to instance of `0x03` (nullable).
    uint32_t ptr5;

    // Null
    uint32_t un3;

    uint32_t TAIL;
    operator x05<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};
#endif

static_assert(sizeof_until_tail<x05<A_160>>() == 60);
static_assert(sizeof_until_tail<x05<A_172>>() == 68);

#endif // X_5_H
